package com.leet.code.simple_array;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:    1380.矩阵中的幸运数
 * @author: WYG
 * @time: 2021/1/3 14:34
 */

public class LuckyNumbers {

    public List<Integer> luckyNumbers (int[][] matrix) {
        List<Integer> res = new ArrayList<>();
        for (int i = 0; i < matrix.length; i++) {
            boolean flag = true;
            int min = 100000;
            int temp = 0;
            for (int j = 0; j < matrix[0].length; j++) {
                if (matrix[i][j] < min) {
                    min = matrix[i][j];
                    temp = j;
                }
            }
            for (int k = 0; k < matrix.length; k++) {
                if (min < matrix[k][temp]) {
                    flag = false;
                }
            }
            if (flag) {
                res.add(min);
            }
        }
        return res;
    }

}
